<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />

<title>月子服务列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 美国服务 <span class="c-gray en">&gt;</span> 月子服务 <a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="pd-20" style="padding-top: 5px;">
	<div class="cl pd-5 bg-1 bk-gray"> <span class="l"><a class="btn btn-primary radius" onclick="month_add('','month-add.html?url=month.html')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加服务</a></span><label><a id="com" style="color:blue;" title="评论" href="javascript:;" onclick="comment('评论','comment-list.html?sid=b8ed798fdc8a44baa6ca8b3aec8ba083');" class="ml-5"><i class="Hui-iconfont">评论</i></a></label></div>
		<div class="mt-20">
		<table class="table table-border table-bordered table-bg table-hover table-sort">
			<thead>
				<tr class="text-c">
					<th width="100">名称</th>
					<th width="100">图片</th>
					<th width="100">简介</th>
					<th width="100">操作</th>
				</tr>
			</thead>
			<tbody id="str">
			</tbody>
		</table>
	</div>
</div>

<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="lib/layer/1.9.3/layer.js"></script> 
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script> 
<script type="text/javascript" src="js/H-ui.js"></script> 
<script type="text/javascript" src="js/H-ui.admin.js"></script>
<script type="text/javascript">

$(function(){
	demo();

//以下将以jquery.ajax为例，演示一个异步分页
function demo(curr){
	$.ajax( {  
	     url:'/baby/usaBabyMonth/queryUsaBabyMonth',// 跳转到 action  
	     data:{pageNum : curr,menutype:"b8ed798fdc8a44baa6ca8b3aec8ba083"},  
	     type:'post',  
	     cache:false,  
	     dataType:'json',  
	     success:function(data) { 
	     	if(data.code == '2000' ){ 
	             // alert(data.data.totalRowNumber); 
	             console.log(data);
	             if(data.data == null){
	             	alert(data.message);
	             	return;
	             }
	             var datalist= data.data.dataList;
	             //有新评论 显示红色style="color:red;"
	             var flag = datalist[0].commentNew;
	             if(flag){
	            	 $("#com").css("color","red")
	             }
	             //拼页面
	             var htmlstr='';
	             for (var i=0;i<datalist.length;i++){
	             	var obj = datalist[i];//获取单个数据对象
	             	var sid = '\'' +obj.sid+ '\'';
	             	/* if(obj.type == '1'){
	             		var type ="待产生活";
	             	}else if(obj.type == '2'){
	             		var type = "月子生活";
	             	}else if(obj.type == '3'){
	             		var type = "母婴护理";
	             	} */
	             	//console.log(obj);
	             	htmlstr+='<tr class="text-c">'
	             	+'<td>'+obj.title+'</td>'
	             	+'<td><img src="'+obj.img.realPicUrl+'" alt="" style="height:150px;"></td>'
	             	+'<td>'+obj.introduce+'</td>'
	             	+'<td class="td-manage">'
	             	+'<a style="text-decoration:none" class="ml-5" href="month-edit.html?sid='+obj.sid+'&url=month.html" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a style="text-decoration:none" class="ml-5 delate"  onClick="picture_del(this,\''+obj.sid+'\')" value='+obj.sid+'href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a></td>'
	             	+'</tr>'
	             }
	             document.getElementById("str").innerHTML =htmlstr 
	            laypage({
				    cont: $('#page1'), //容器。值支持id名、原生dom对象，jquery对象,
				    pages:data.data.totalRowNumber, //总页数
				    skip: true, //是否开启跳页
				    groups: 5, //连续显示分页数
				    curr: data.data.currentPage, //当前页
				    pages:data.data.totalPage,
				    jump: function(obj, first){
				    //得到了当前页，用于向服务端请求对应数据
				    var curr = obj.curr;
				    if(!first){
				    	demo(curr);	
				    }
				}
			});
	        }else{  
	        	alert(data.message); 
	        	console.log(data);  
	        }  
	    }, 
	    error : function() {      
	    	alert("异常！");  
	    }  
	});
};
//运行

});


/*添加*/
function month_add(title,url,w,h){
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}


/*图片-删除*/
function picture_del(obj,id){
	// var sid = $(this).attr('sid');
	$.ajax( {  
		url:'/baby/usaBabyMonth/deleteUsaBabyMonth',// 跳转到 action  
		data:{id:id},  
		type:'post',  
		cache:false,  
		dataType:'json',  
		success:function(data) { 
	     	console.log(data);
	     	if(data.code =="2000" ){ 
	     		location.reload(); 
	     	}else{
	     		alert(data.message);
	     	}
	    }, 
	    error : function() {      
	    	alert("异常！");  
		}  
	});
}

//评论
function comment(title,url,id,w,h){
	//alert(id);
	layer_show(title,url,w,h);
}


</script> 
</body>
</html>